package fileAndIO;

import org.junit.Test;

import java.io.*;
import java.nio.charset.StandardCharsets;

public class Test9 {
    @Test
    public void test() {
        try (
                FileInputStream fis = new FileInputStream("C:\\Users\\83726\\ccc\\aa.txt");
                InputStreamReader isr = new InputStreamReader(fis, StandardCharsets.UTF_8);
                BufferedReader br = new BufferedReader(isr);
        ) {
            String str;
            while ((str = br.readLine()) != null) {
                System.out.println(str);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    // 它没有finally，也不需要程序员去关闭资源对象，无论是否发生异常，都会关闭资源对象
}
